<?php
	require_once "includes/pagination.php";
	$itemPerPage=10;
	if($_SESSION['user_id_sess']=="") {
		echo "<script type='text/javascript'> window.location='index.php?signin&url=mylist'; </script>";
	}
	$userId = $_SESSION['user_id_sess'];
?>
<?
if($sellflag!=1)
{
?>
<div id='panel'>
<table width="100%" border="0">
  <tr class='head-tr'>
    <td><strong>Your items being sold</strong></td>
  </tr>
  <tr>
    <td>		
      	 
		 <?php
		 	//delete single product		 
			if(!empty($_POST['hidDelPro'])) {
				$proId=$_POST['hidDelPro'];
				$sqlDelPro="Delete from tbl_product where product_id=$proId";
				$rstDelPro=mysql_query($sqlDelPro);
				if($rstDelPro) { 
					//$imgPaths=getImagePath($proId);
					//if($imgPaths[0]!="") { unlink($imgPaths[0]); }
					//if($imgPaths[1]!="") { unlink($imgPaths[1]); }
					//if($imgPaths[2]!="") { unlink($imgPaths[2]); }
					echo "<div id='suc-msg'> Your product deleted. </div><br>"; 
				}	
				else {
					echo "<div id='err-msg'> Your product could not be deleted. </div><br>";
				}
			}			
			   
		 ?>
		 <form name="frmProlist" id="frmProlist" method="post" action="">
		 <input type="hidden" name="hidDelPro" id="hidDelPro">
         <input type="hidden" name="hidDelProKey" id="hidDelProKey">
		 <?php		   
				   $sqlSelPro="SELECT * FROM tbl_product where posted_by='$userId' ORDER BY product_id DESC";
				   $rstSelPro=mysql_query(getPagingQuery($sqlSelPro,$itemPerPage));				  
				   $num=mysql_num_rows($rstSelPro);
				   
				   if($num==0)
					{
					  echo "<div style='border-top:1px solid #CCCCCC;'> </div><br>";
					  echo "<p style='padding:5px;'>No items found on your list...</p><br>";
					  echo "<div style='border-top:1px solid #CCCCCC;'> </div><br>";
					}
				   else {	?>
				   		  <br><table width='100%' border='0' align='center' cellspacing='0'>
						  <tr class='head-tr'>
								  <td width="5%"><strong>S.No</strong></td>								
								  <td width="15%"><strong>Product name </strong></td>
								  <td width="11%"><strong>Condition</strong></td>
								  <td width="10%"  align='center'><strong># of Sellers</strong></td>
								  <td width="8%"><strong>Pick up</strong></td>
								  <td width="7%"><strong>Qty</strong>.</td>
								  <td width="12%"  align='center'> <strong> Comission (PP)</strong></td>
								  <td width="20%" align='right'> <strong>Price + shipp (PP)</strong></td>
							      <td width="12%">&nbsp;</td>
						    </tr>				 
						 <?php
						 $r=1;
						 while($rowSelPro=mysql_fetch_array($rstSelPro))
					     {						   
						   $productId=$rowSelPro['product_id'];
						   $productName=wordFormater($rowSelPro['product_name'],10);
						   $productTitle = $rowSelPro['product_name'];					   
						   $productPrice=$rowSelPro['product_price'];
						   $productThumb=$rowSelPro['product_thumbnail'];
						   $productImage=$rowSelPro['product_image'];
						   $productSellingType=$rowSelPro['selling_type'];
						   $productShipping=$rowSelPro['shipping'];
						   $productProCondition=$rowSelPro['pro_condition'];
						   $productQuantity=$rowSelPro['quantity'];
						   $commission=$rowSelPro['commission'];
						   $postedBy=$rowSelPro['posted_by'];
						   $postedDate=$rowSelPro['posted_date'];
						   $bargainDate = $rowSelPro['bargain_duration'];
						   if(!empty($productShipping))
						    $productShipping=" + ".$productShipping;
						   else
						     $productShipping=" + Free";
						   $timeLeft = getRemainingTime($bargainDate);
						   if($timeLeft < 0) {
						   		$timeLeft = "<font color='red'>Listing Expired</font>";
						    }
						  
						   					   
						   echo "<tr>
						   		 <td height='28'> $r </td>					         
								 <td> <a href='index.php?SellProduct=$productId' title='$productTitle'> $productName </a> </td>
								 <td>Reburished</td>
								 <td align='center'>3</td>
								 <td>$productSellingType</td>
								 <td align='center'>$productQuantity</td>
								 <td  align='right'>$commission</td>
								 <td align='right'>$productPrice $productShipping</td>
						      	 <td><a href='index.php?editlist=$productId'>Edit</a> | <a href='javascript:void(0);' onClick='funDelProduct('frmProlist','prod',$productId)'>Delete</a></td>
							   </tr>";	
							echo "<tr>
									 <td colspan='9'> <div style='border-top:1px solid #CCCCCC;'> </div> </td>
								  </tr>";   			  
						 	$r++;
						 } ?>
						</table>				    	
						<?php
					} 				
	?>
	</form>
	</td>
</tr>	

<tr>
	<td><div align="center"><?php
		   $link="mySwapen";
		   echo $disp=getPagingLink($sqlSelPro,$itemPerPage,$link);							   
	 ?></div>
	</td>
</tr>
</table>
<?
}
?>
</div>